home *** CD-ROM | disk | FTP | other *** search
/ The CICA Windows Explosion! / The CICA Windows Explosion! - Disc 2.iso / programr / cprot20h.zip / CPTEST.BAS < prev    next >
BASIC Source File  |  1995-07-07  |  6KB  |  253 lines

  1. Const Cfgname_hlp = "Write the name of your security file here."
  2. Const Cfgmake_hlp = "Press to make a new security file with a new serial number."
  3. Const Feature_hlp = "The feature code ( 1 - 15 ) for which you want to make a registration code."
  4. Const Regmake_hlp = "Press to create a matching registration code."
  5. Const Uname_hlp = "The name of the registered user that you want in the security file."
  6. Const Ucompany_hlp = "The name of the users company"
  7. Const Setnames_hlp = "Press to write the above names to the security file."
  8. Const Getnames_hlp = "To retreive the user and company names from the security file."
  9. Const Register_hlp = "To write the registrtation code into the security file."
  10. Const Checkreg_hlp = "To find out whether the security file contains a registration code."
  11. Const CheckCode_hlp = "Check which feature the registration code in the security file enables."
  12. Const Start_hlp = "Start the usage timer and increment the 'Times used' counter."
  13. Const Stopnow_hlp = "To stop the usage timer and display usage statistics."
  14. Const Goodbye_hlp = "To quit this testprogram."
  15.  
  16.  
  17. Sub Cfgmake_Click ()
  18.  
  19.     file$ = Cfgname.Text
  20.     a = cpCFGMake(file$, magicnumber, filevesion)
  21.     fileisok = 1
  22.     sernum$ = String$(15, 0)
  23.     a = cpGetSernum(file$, sernum$)
  24.     Snumber.Text = sernum$
  25.     regcode.Text = ""
  26.  
  27.     Uname1.Text = ""
  28.     Ucompany1.Text = ""
  29.  
  30.     Thour.Text = ""
  31.     Tmin.Text = ""
  32.     Tsec.Text = ""
  33.     Chour.Text = ""
  34.     CMin.Text = ""
  35.     Csec.Text = ""
  36.     Ttimes.Text = ""
  37.  
  38.     Checkmessage.Text = ""
  39.     Codecheck.Text = ""
  40. End Sub
  41.  
  42. Sub Regmake_Click ()
  43.     fcode = Val(Feature.Text)
  44.     rcode$ = String$(15, 0)
  45.     ser$ = Snumber.Text
  46.     a% = cpMakeRegCode(fcode, ser$, rcode$)
  47.     regcode.Text = rcode$
  48. End Sub
  49.  
  50. Sub Feature_Change ()
  51. regcode.Text = ""
  52. End Sub
  53.  
  54. Sub Uname_Change ()
  55. Uname1.Text = ""
  56. End Sub
  57.  
  58. Sub Ucompany_Change ()
  59. Ucompany1.Text = ""
  60. End Sub
  61.  
  62. Sub Setnames_Click ()
  63.     If fileisok Then
  64.     Uname1.Text = ""
  65.     Ucompany1.Text = ""
  66.     u_name$ = uname.Text
  67.     u_comp$ = Ucompany.Text
  68.     cfg_name$ = Cfgname.Text
  69.     a = cpSetRegisteredNames(cfg_name$, u_name$, u_comp$)
  70.     End If
  71. End Sub
  72.  
  73. Sub Getnames_Click ()
  74.     If fileisok Then
  75.     u_name$ = String$(28, 0)
  76.     u_comp$ = String$(28, 0)
  77.     cfg_name$ = Cfgname.Text
  78.     a = cpGetRegisteredName(cfg_name$, u_name$)
  79.     Uname1.Text = u_name$
  80.     a = cpGetRegisteredCompany(cfg_name$, u_comp$)
  81.     Ucompany1.Text = u_comp$
  82.     End If
  83. End Sub
  84.  
  85. Sub Checkreg_Click ()
  86.     If fileisok Then
  87.     a1$ = "Program is "
  88.     a2$ = "registered"
  89.     cfg_name$ = Cfgname.Text
  90.     a = cpIsRegistered(cfg_name$)
  91.     If a = 0 Then
  92.         yes$ = ""
  93.     Else
  94.         yes$ = "not "
  95.     End If
  96.     Checkmessage.Text = a1$ + yes$ + a2$
  97.     Else
  98.     Checkmessage.Text = " No file! "
  99.     End If
  100. End Sub
  101.  
  102. Sub Register_Click ()
  103.     If fileisok Then
  104.     reg_code$ = regcode.Text
  105.     cfg_name$ = Cfgname.Text
  106.     If reg_code$ > "" Then
  107.         a = cpRegisterProgram(cfg_name$, reg_code$)
  108.     End If
  109.     Checkmessage.Text = ""
  110.     Codecheck.Text = ""
  111.     End If
  112. End Sub
  113.  
  114. Sub CheckCode_Click ()
  115.     If fileisok Then
  116.     code$ = String$(15, 0)
  117.     cfg_name$ = Cfgname.Text
  118.     a = cpCheckRegCode(cfg_name$, code$)
  119.     If a = 0 Or a = WRONG_CODE Then
  120.         t$ = "Regcode incorrect!"
  121.     ElseIf a < 0 Then
  122.         t$ = "Fileproblems!"
  123.     Else
  124.         t$ = "Feature " + Str$(a) + " registered"
  125.     End If
  126.     Else
  127.     t$ = " No file! "
  128.     End If
  129. Codecheck.Text = t$
  130.  
  131. End Sub
  132.  
  133. Sub Start_Click ()
  134.     Thour.Text = ""
  135.     Tmin.Text = ""
  136.     Tsec.Text = ""
  137.     Chour.Text = ""
  138.     CMin.Text = ""
  139.     Csec.Text = ""
  140.     Ttimes.Text = ""
  141.     If fileisok Then
  142.     cfg_name$ = Cfgname.Text
  143.     a = cpStartProgram(cfg_name$)
  144.     End If
  145. End Sub
  146.  
  147. Sub Stopnow_Click ()
  148. Dim times As Integer, t_hour As Integer, t_min As Integer, t_sec As Integer, c_hour As Integer, c_min As Integer, c_sec As Integer
  149. If Ttimes.Text = "" And fileisok Then
  150.     cfg_name$ = Cfgname.Text
  151.     a = cpEndProgram(cfg_name$)
  152.     a = cpGetUStatistics(cfg_name$, times, t_hour, t_min, t_sec, c_hour, c_min, c_sec)
  153.  
  154.     Thour.Text = Str$(t_hour)
  155.     Tmin.Text = Str$(t_min)
  156.     Tsec.Text = Str$(t_sec)
  157.     Chour.Text = Str$(c_hour)
  158.     CMin.Text = Str$(c_min)
  159.     Csec.Text = Str$(c_sec)
  160.     Ttimes.Text = Str$(times)
  161. End If
  162. End Sub
  163.  
  164. Sub Goodbye_Click ()
  165. Unload Form1
  166. End Sub
  167.  
  168. Sub Cfgname_GotFocus ()
  169. Hlpbar.Text = Cfgname_hlp
  170. End Sub
  171.  
  172. Sub Cfgmake_GotFocus ()
  173. Hlpbar.Text = Cfgmake_hlp
  174. End Sub
  175.  
  176. Sub CheckCode_GotFocus ()
  177. Hlpbar.Text = CheckCode_hlp
  178. End Sub
  179.  
  180. Sub Checkreg_GotFocus ()
  181. Hlpbar.Text = Checkreg_hlp
  182. End Sub
  183.  
  184. Sub Feature_GotFocus ()
  185. Hlpbar.Text = Feature_hlp
  186. End Sub
  187.  
  188. Sub Getnames_GotFocus ()
  189. Hlpbar.Text = Getnames_hlp
  190. End Sub
  191.  
  192. Sub Goodbye_GotFocus ()
  193. Hlpbar.Text = Goodbye_hlp
  194. End Sub
  195.  
  196. Sub Regmake_GotFocus ()
  197. Hlpbar.Text = Regmake_hlp
  198. End Sub
  199.  
  200. Sub Setnames_GotFocus ()
  201. Hlpbar.Text = Setnames_hlp
  202. End Sub
  203.  
  204. Sub Start_GotFocus ()
  205. Hlpbar.Text = Start_hlp
  206. End Sub
  207.  
  208. Sub Stopnow_GotFocus ()
  209. Hlpbar.Text = Stopnow_hlp
  210. End Sub
  211.  
  212. Sub Ucompany_GotFocus ()
  213. Hlpbar.Text = Ucompany_hlp
  214. End Sub
  215.  
  216. Sub Uname_GotFocus ()
  217. Hlpbar.Text = Uname_hlp
  218. End Sub
  219.  
  220. Sub Register_GotFocus ()
  221. Hlpbar.Text = Register_hlp
  222. End Sub
  223.  
  224. Sub Cfgname_LostFocus ()
  225.     fil$ = Cfgname.Text
  226.     If magicnumber = cpGetFileinfo(fil$, vernum&) Then
  227.     fileisok = 1
  228.     sernum$ = String$(15, 0)
  229.     a = cpGetSernum(fil$, sernum$)
  230.     Snumber.Text = sernum$
  231.     Else
  232.     fileisok = 0
  233.     Snumber.Text = ""
  234.     End If
  235.  
  236.     regcode.Text = ""
  237.  
  238.     Uname1.Text = ""
  239.     Ucompany1.Text = ""
  240.  
  241.     Thour.Text = ""
  242.     Tmin.Text = ""
  243.     Tsec.Text = ""
  244.     Chour.Text = ""
  245.     CMin.Text = ""
  246.     Csec.Text = ""
  247.     Ttimes.Text = ""
  248.  
  249.     Checkmessage.Text = ""
  250.     Codecheck.Text = ""
  251. End Sub
  252.  
  253.